<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta charset="UTF-8">
  <title>投票详情</title>
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/common.css">
  <link rel="stylesheet" href="../css/A_A_information.css">
  <script type="text/javascript" src="../lib/js/evm.js"></script>
  <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
  <script type="text/javascript" src="../lib/js/key.js"></script>
  <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/model.js"></script>

  <style>
    .list-video-vote.active .list-vote-title {
      background-color: orange;
    }
    .list-video-vote,.list-row-vote .cur.curActive {
      background: url(../images/items-bg.png) no-repeat;
      background-size: cover;
      color: #fff;
    }

    .list-text-container {
      width: 100%;
      box-sizing: border-box;
      height: 80px;
      padding-left: 15px;
      line-height: 80px;
    }

    .list-text{
      width: 140px;
      font-size: 28px;
      color: #fff;
      text-align: justify;
      text-align-last: justify;
    }
    .list-vote-info {
      display: inline-block;
      width: 800px;
      height: auto;
      color: #fff;
      font-size: 28px;

    }
  </style>
</head>

<body>
  <div class="forum-bg" id="forumMain">
    <ul class="nav-bg" id="nav-bg">

    </ul>
    <div class="list-bg">
      <div class="list-con" id="list-con"></div>
      <p class="page-show"><span id="now_page">0</span>/<span id="total_page">0</span>
      </p>
    </div>

  </div>

</body>
<script>
  var modelIndex = {
    disUser: false,
    index: 0, //导航栏初始位置
    menuKey: '',
    menuPageSize: 5, //导航栏模块数量
    pageSize: 1, //主模块数量
    type: '',
    crumbs: leftModel[TV.GetParam("model")].name,
    structure: 2, //上下结构  默认1是左右，2是上下结构
    menuContainerId: 'nav-bg', //包含导航栏模块的标签id
    menuListName: 'nav', //导航栏模块名称class
    mainContainerId: 'list-con', //包含主模块的标签id
    mainlistName: '', //主模块名称
    id: leftModel[TV.GetParam("model")],
  }

  var leftData = leftModel[TV.GetParam("model")].arry;

  function getMenus(page, number) {
    if (typeof number == 'number') {
      // modelIndex.mainContainerId = leftData[number].list_name;
    }
    left.paint(page, number);
    $(".nav").css("width",(1/leftData.length)*100+"%")

  }

  function getMessage(id, page, pos, index) {
    if (id == 666) {
      var param = {
        page: page,
        pagesize: modelIndex.pageSize,
        id: TV.GetParam('id'),
        // area_id: $.cookie('TV_CST_AREA'),
        // device: 'tv'
      }
      GetDatas('getVoteDetail', param, function (err, res) {
        var mess = res.data;
        var str = '';
        console.log(mess)
        if (mess.options.length > 0) {
          for (var i = 0; i < mess.options.length; i++) {
            var img = '';
            if (!mess.options[i].img) {
              img = '../images/base.png'
            } else {
              img = API_URL.imgURL + mess.options[i].img
            }
            str += "<div class="+modelIndex.mainlistName+" data-id=" + mess.options[i].id + " data-tpe=" + mess.options[i].tpe + " >";
            //通过数组的方式 将所有的对应项都输出来
            // str += '<div class="list-info">'

            str += '<div class="list-imgBar">'
            str += "<img class='list-img' src=" + img + ">";
            str += '</div>'
            if (mess.options[i].tpe == 5 || mess.options[i].tpe == 4) {
              str += "<div class='listPlay' ><img src='../images/play.png'></div>";
            }
            str += "<div class='list-vote-title'><p>" + mess.options[i].title + '</p></div>'
            str += '<div class="vote-container"><span class="tickets">' + mess.options[i].tickets + '</span><span class="text">票</span><div class="cur" data-id="' + mess.options[i].id + '"">投票</div></div>'
            str += '</div>'
            // str += '</div>'

          }
        } else {
          str += '<h1>暂无数据</h1>';
          $('.page-show').css('display', 'none');
        }
        $('#list-con').html(str);
        $('.page-show').css('display', 'block');
        $('#now_page').html(page)
        $('#total_page').html(mess.totalpage)
        MessOpt(page, mess.totalpage, pos, index);
      })
    }
    else if (id == 999) {
      var param = {
        // page: page,
        // pagesize: pageSize,
        id: TV.GetParam('id'),
        // area_id: $.cookie('TV_CST_AREA'),
        // device: 'tv'
      }
      GetDatas('getVoteDetail', param, function (err, res) {
        var mess = res.data;
        var str = '';
        console.log(mess)
        if (mess.vote ) {
          str += '<div class="list-text-container"><span class="list-text">投票标题：</span><span class="list-vote-info">' + mess.vote.title + '</span></div>' 
          str += '<div class="list-text-container"><span class="list-text">投票规则：</span><span class="list-vote-info">' + mess.vote.brief + '</span></div>' 
          str += '<div class="list-text-container"><span class="list-text">开始时间：</span><span class="list-vote-info">' + mess.vote.format_start_time + '</span></div>' 
          str += '<div class="list-text-container"><span class="list-text">截至时间：</span><span class="list-vote-info">' + mess.vote.format_end_time + '</span></div>' 
      } else {
        str += '<h1>暂无数据</h1>';
        $('.page-show').css('display', 'none');
      }
        $('#list-con').html(str);
      $('.page-show').css('display', 'none');
      $('#now_page').html(page)
      $('#total_page').html(mess.totalpage)
      MessOpt(page, mess.totalpage, pos, index);
    })
  }

    // right.toggleFocus();
  }

  function direEnter(status, id, index) {
    console.log(status)
    if(status == 0) {
      var tid = $('.curActive').attr('data-id');
    var access_token = $.cookie('TV_CST_TOKEN');
    // var ids = $('.active').attr('data-id');
    console.log(tid)
    // console.log(id)
    var param = {
      access_token: access_token,
      id: TV.GetParam('id'),
      oid: tid,
    }
    GetDatas('voteTo', param, function (err, res) {
      console.log(res)
      if (res.code == 0) {
        TV.PromptMsg("投票成功")
        $('.active .tickets').html(parseInt($('.active .tickets').html()) + 1)

      } else if (res.code == 10002) {

        if (TV.UserMess(1)) {
          TV.userLogin();
          direEnter(index);
        } else {
          TV.PromptMsg("请重新登陆")
        }
      } else {
        // console.log(res)
        var message = res.message
        TV.PromptMsg(message)
      }
    })
    }
    else {
      window.location.href = "./play-shouye.html"
    }

  }
</script>
<script type="text/javascript" src="../js/twoPageList.js"></script>

</html>